/* This defines the commands supported by this client */
struct
{
char *name;
void (*fn)();
char *description;
} commands[] =
{
{"ls",cmd_dir,"<mask> list the contents of the current directory"},
{"dir",cmd_dir,"<mask> list the contents of the current directory"},
{"lcd",cmd_lcd,"[directory] change/report the local current working directory"},
{"cd",cmd_cd,"[directory] change/report the remote directory"},
{"pwd",cmd_pwd,"show current remote directory (same as 'cd' with no args)"},
{"get",cmd_get,"<remote name> [local name] get a file"},
{"mget",cmd_mget,"<mask> get all the matching files"},
{"put",cmd_put,"<local name> [remote name] put a file"},
{"mput",cmd_mput,"<mask> put all matching files"},
{"rename",cmd_rename,"<src> <dest> rename some files"},
{"more",cmd_more,"<remote name> view a remote file with your pager"},
{"mask",cmd_select,"<mask> mask all filenames against this"},
{"del",cmd_del,"<mask> delete all matching files"},
{"rm",cmd_del,"<mask> delete all matching files"},
{"mkdir",cmd_mkdir,"<directory> make a directory"},
{"md",cmd_mkdir,"<directory> make a directory"},
{"rmdir",cmd_rmdir,"<directory> remove a directory"},
{"rd",cmd_rmdir,"<directory> remove a directory"},
{"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput"},
{"recurse",cmd_recurse,"toggle directory recursion for mget and mput"},
{"translate",cmd_translate,"toggle text translation for printing"},
{"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get"},
{"print",cmd_print,"<file name> print a file"},
{"printmode",cmd_printmode,"<graphics or text> set the print mode"},
{"queue",cmd_queue,"show the print queue"},
{"cancel",cmd_cancel,"<jobid> cancel a print queue entry"},
{"stat",cmd_stat,"<file> get info on a file (experimental!)"},
{"quit",send_logout,"logoff the server"},
{"q",send_logout,"logoff the server"},
{"exit",send_logout,"logoff the server"},
{"newer",cmd_newer,"<file> only mget files newer than the specified local file"},
{"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit"},
{"tar",cmd_tar,"tar current directory to <file name>" },
DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
get_myname(*myname?NULL:myname,&myip);
strupper(myname);
if (*query_host)
{
int ret = 0;
sprintf(service,"\\\\%s\\IPC$",query_host);
strupper(service);
connect_as_ipc = True;
if (open_sockets(port))
{
#if 0
*username = 0;
#endif
if (!send_login(NULL,NULL,True,True))
return(1);
server_info();
if (!browse_host(True)) {
sleep(1);
browse_host(True);
}
if (!list_servers()) {
sleep(1);
list_servers();
}
send_logout();
close_sockets();
}
return(ret);
}
if (message)
{
int ret = 0;
if (open_sockets(port))
{
pstring inbuf,outbuf;
bzero(outbuf,smb_size);
if (!send_session_request(inbuf,outbuf))
return(1);
send_message(inbuf,outbuf);
close_sockets();
}
return(ret);
}
if (open_sockets(port))
{
if (!process())
{
close_sockets();
return(1);
}
close_sockets();
}
else
return(1);
return(0);
}
/* error code stuff - put together by Merik Karman
merik@blackadder.dsh.oz.au */
typedef struct
{
char *name;
int code;
char *message;
} err_code_struct;
/* Dos Error Messages */
err_code_struct dos_msgs[] = {
{"ERRbadfunc",1,"Invalid function."},
{"ERRbadfile",2,"File not found."},
{"ERRbadpath",3,"Directory invalid."},
{"ERRnofids",4,"No file descriptors available"},
{"ERRnoaccess",5,"Access denied."},
{"ERRbadfid",6,"Invalid file handle."},
{"ERRbadmcb",7,"Memory control blocks destroyed."},
{"ERRnomem",8,"Insufficient server memory to perform the requested function."},
{"ERRbadmem",9,"Invalid memory block address."},
{"ERRbadenv",10,"Invalid environment."},
{"ERRbadformat",11,"Invalid format."},
{"ERRbadaccess",12,"Invalid open mode."},
{"ERRbaddata",13,"Invalid data."},
{"ERR",14,"reserved."},
{"ERRbaddrive",15,"Invalid drive specified."},
{"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
{"ERRdiffdevice",17,"Not same device."},
{"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
{"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
{"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
{"ERRbadpipe",230,"Pipe invalid."},
{"ERRpipebusy",231,"All instances of the requested pipe are busy."},
{"ERRpipeclosing",232,"Pipe close in progress."},
{"ERRnotconnected",233,"No process on other end of pipe."},
{"ERRmoredata",234,"There is more data to be returned."},
{NULL,-1,NULL}};
/* Server Error Messages */
err_code_struct server_msgs[] = {
{"ERRerror",1,"Non-specific error code."},
{"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
{"ERRbadtype",3,"reserved."},
{"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
{"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
{"ERRinvnetname",6,"Invalid network name in tree connect."},
{"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
{"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
{"ERRqtoobig",50,"Print queue full -- no space."},
{"ERRqeof",51,"EOF on print queue dump."},
{"ERRinvpfid",52,"Invalid print file FID."},
{"ERRsmbcmd",64,"The server did not recognize the command received."},
{"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
{"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
{"ERRreserved",68,"reserved."},
{"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
{"ERRreserved",70,"reserved."},
{"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
{"ERRpaused",81,"Server is paused."},
{"ERRmsgoff",82,"Not receiving messages."},
{"ERRnoroom",83,"No room to buffer message."},
{"ERRrmuns",87,"Too many remote user names."},
{"ERRtimeout",88,"Operation timed out."},
{"ERRnoresource",89,"No resources currently available for request."},
{"ERRtoomanyuids",90,"Too many UIDs active on this session."},
{"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
{"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
{"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
{"ERRcontmpx",252,"Continue in MPX mode."},
{"ERRreserved",253,"reserved."},
{"ERRreserved",254,"reserved."},
{"ERRnosupport",0xFFFF,"Function not supported."},
{NULL,-1,NULL}};
/* Hard Error Messages */
err_code_struct hard_msgs[] = {
{"ERRnowrite",19,"Attempt to write on write-protected diskette."},
{"ERRbadunit",20,"Unknown unit."},
{"ERRnotready",21,"Drive not ready."},
{"ERRbadcmd",22,"Unknown command."},
{"ERRdata",23,"Data error (CRC)."},
{"ERRbadreq",24,"Bad request structure length."},
{"ERRseek",25 ,"Seek error."},
{"ERRbadmedia",26,"Unknown media type."},
{"ERRbadsector",27,"Sector not found."},
{"ERRnopaper",28,"Printer out of paper."},
{"ERRwrite",29,"Write fault."},
{"ERRread",30,"Read fault."},
{"ERRgeneral",31,"General failure."},
{"ERRbadshare",32,"A open conflicts with an existing open."},
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
{"ERRwrongdisk",34,"The wrong disk was found in a drive."},
{"ERRFCBUnavail",35,"No FCBs are available to process request."},
{"ERRsharebufexc",36,"A sharing buffer has been exceeded."},